		TITLE	LEDATA - Copyright (c) SLR Systems 1994
		SUBTTL	Contains Confidential and Proprietary material

		INCLUDE MACROS
		INCLUDE	SYMBOLS
		INCLUDE	SEGMENTS
		INCLUDE	CDDATA
		INCLUDE	IO_STRUC

		PUBLIC	LEDATA,LEDATA32,LIDATA,LIDATA32,RIDATA32,REDATA,RIDATA,REDATA32,OBJ_E


		.DATA

		EXTERNDEF	CLASS_TYPE:BYTE,LDATA_TYPE:BYTE,REFERENCE_FLAGS:BYTE,MCD_FLAGS:BYTE,DEBUG_TYPES_SELECTED:BYTE

		EXTERNDEF	DEFAULT_SIZE:DWORD,LDATA_SEGMOD_GINDEX:DWORD,MYCOMDAT_LINDEX:DWORD

		EXTERNDEF	LAST_DATA_PTR:DWORD,PREV_DATA_PTR:DWORD,LDATA_LOC:DWORD,COMDAT_DATA_PTR:DWORD,COMDAT_OFFSET:DWORD

		EXTERNDEF	SEGMOD_LARRAY:LARRAY_STRUCT,SYMBOL_LARRAY:LARRAY_STRUCT,SYMBOL_GARRAY:STD_PTR_S
		EXTERNDEF	SEGMENT_GARRAY:STD_PTR_S,SEGMOD_GARRAY:STD_PTR_S


		.CODE	PASS1_TEXT

		EXTERNDEF	OBJ_PHASE:PROC,BAD_RECORD:PROC,FAKE_LEDATA:PROC,COMDAT_VIRDEF_CONT:PROC


RIDATA32	PROC

		MOV	AL,MASK BIT_LI+MASK BIT_32	;ITERATED, 32-BIT
		JMP	RDATA_COMMON1

		DOLONG	L2
		DOLONG	L3

RIDATA		LABEL	PROC

		MOV	AL,MASK BIT_LI			;ITERATED, 16-BIT
		JMP	RDATA_COMMON

REDATA32	LABEL	PROC

		MOV	AL,MASK BIT_32+MASK BIT_LE	;NORMAL, 32-BIT
		JMP	RDATA_COMMON1


REDATA		LABEL	PROC
		;
		;DS:SI IS DATA RECORD
		;
		MOV	AL,MASK BIT_LE		;NORMAL, 16-BIT
RDATA_COMMON:
if	fg_phar
		OR	AL,BPTR DEFAULT_SIZE
endif
RDATA_COMMON1:
		MOV	LDATA_TYPE,AL

		NEXT_INDEX	L2		;GET GROUP LINDEX
		MOV	EDX,EAX
		;
		;IF ASEG, IGNORE
		;IF CODEVIEW NOT SELECTED, BUT CODEVIEW SEGMENT, IGNORE
		;
		NEXT_INDEX	L3		;GET SEGMENT LINDEX
		OR	EDX,EAX
		JNZ	LDATA_COMMON2
		CALL	BAD_RECORD
		RET

RIDATA32	ENDP


LIDATA32:
		MOV	AL,MASK BIT_LI+MASK BIT_32	;ITERATED, 32-BIT
		JMP	LDATA_COMMON1

LIDATA:
		MOV	AL,MASK BIT_LI			;ITERATED, 16-BIT
		JMP	LDATA_COMMON

LEDATA32:
		MOV	AL,MASK BIT_32+MASK BIT_LE	;NORMAL, 32-BIT
		JMP	LDATA_COMMON1

LDATA_MVIRDEF::
		;
		;PROBABLY A VIRDEF REFERENCE...
		;
		CONVERT_MYCOMDAT_EAX_ECX
		ASSUME	ECX:PTR MYCOMDAT_STRUCT

		JC	LDATA_NVIRDEF
		MOV	MYCOMDAT_LINDEX,EAX
		;
		;ARE WE KEEPING THIS SEGMOD ?
		;
		MOV	AL,[ECX]._MCD_FLAGS
		TEST	AL,MASK MCD_KEEPING_THIS
		JZ	SKIPIT_VIRDEF
		MOV	MCD_FLAGS,DL

		BITT	PACKFUNCTIONS_FLAG
		MOV	DL,MASK S_HARD_REF
		JZ	L70$
		TEST	AL,MASK MCD_HARD_REF
		JNZ	L70$
		MOV	DL,MASK S_SOFT_REF
L70$:
		MOV	REFERENCE_FLAGS,DL
		MOV	EDX,[ECX]._MCD_SEGMOD_GINDEX

		MOV	CL,LDATA_TYPE
		MOV	EAX,[ESI]		;GET OFFSET
		ADD	ESI,4
		AND	CL,MASK BIT_32
		JNZ	L71$
		AND	EAX,0FFFFH
		SUB	ESI,2
L71$:
		MOV	COMDAT_OFFSET,EAX
		MOV	COMDAT_DATA_PTR,ESI
		JMP	COMDAT_VIRDEF_CONT


SKIPIT_VIRDEF:
		JMP	SKIPIT_1


LEDATA		PROC
		;
		;DS:SI IS DATA RECORD
		;
		MOV	AL,MASK BIT_LE		;NORMAL, 16-BIT
LDATA_COMMON::
if	fg_phar
		OR	AL,BPTR DEFAULT_SIZE
endif
LDATA_COMMON1::
		MOV	LDATA_TYPE,AL
		;
		;IF ASEG, IGNORE
		;IF CODEVIEW NOT SELECTED, BUT CODEVIEW SEGMENT, IGNORE
		;
		NEXT_INDEX	L1		;GET SEGMENT LINDEX
LDATA_COMMON2::
		;CMP	EAX,16K			;MAYBE BVIRDEF?
		;JA	LDATA_MVIRDEF
LDATA_NVIRDEF::
		CONVERT_LINDEX_EAX_EAX		SEGMOD_LARRAY,EDI
LDATA_Y_VIRDEF:
		;
		;IF SAME SEGMENT, SAVE LAST_DATA_PTR
		;
		XOR	EDX,EDX
		MOV	ECX,LDATA_SEGMOD_GINDEX
		RESS	LAST_DATA_COMDAT,DL
		MOV	PREV_DATA_PTR,EDX
		CONVERT	EDI,EAX,SEGMOD_GARRAY
		ASSUME	EDI:PTR SEGMOD_STRUCT

		CMP	ECX,EAX
		JNZ	L3$
		MOV	ECX,LAST_DATA_PTR	;USED BY FARCALLTRANSLATE IF
		MOV	PREV_DATA_PTR,ECX	;OFFSET IS 0
L3$:
		MOV	LDATA_SEGMOD_GINDEX,EAX	;FOR USE BY FIXUPP
		MOV	AL,[EDI]._SM_FLAGS
		MOV	CLASS_TYPE,AL
		TEST	AL,MASK SEG_ASEG
		JNZ	SKIPIT_ASEG		;SKIP ASEGS?
		;
		;IS IT A DEBUG CLASS?
		;
		TEST	AL,MASK SEG_CV_TYPES1 + MASK SEG_CV_SYMBOLS1
		JNZ	SKIPIT_MAYBE		;MAYBE SKIP CV_INFO
SKIPIT_RET:
if	fg_segm
if	fg_norm_exe
		BITT	OUTPUT_SEGMENTED
		JZ	L4$
endif
		MOV	EAX,[EDI]._SM_BASE_SEG_GINDEX		;DON'T INITIALIZE STACK IN SEGMENTED OUTPUT
		CONVERT	EAX,EAX,SEGMENT_GARRAY
		ASSUME	EAX:PTR SEGMENT_STRUCT

		CMP	[EAX]._SEG_COMBINE,SC_STACK
		JZ	SKIPIT_1
L4$:
endif
		MOV	EAX,ESI
		MOV	REFERENCE_FLAGS,MASK S_HARD_REF		;REAL REFERENCE, NOT FROM UNREFERENCED COMDAT
		CALL	FAKE_LEDATA
		RET

		DOLONG	L1

SKIPIT_ASEG:

if	fg_rom
		;
		;IF DOING ABSOLUTE OUTPUT, KEEP THIS DATA...
		;
		BITT	OUTPUT_ABS
		JNZ	SKIPIT_RET

endif

		JMP	SKIPIT_1

SKIPIT_MAYBE:

if	fg_cv
		BITT	CODEVIEW_FLAG		;SKIP IF NOT GENERATING CODEVIEW INFO
		JZ	SKIPIT_1
		MOV	AH,DEBUG_TYPES_SELECTED
		TEST	AL,MASK SEG_CV_TYPES1
		JNZ	SK_MB_TYPES
		;
		;MUST BE LOCAL SYMBOLS INFO
		;
		TEST	AH,MASK FL_DEBUG_LOCALS
		JZ	SKIPIT_1
		JMP	SKIPIT_RET

SK_MB_TYPES:
		TEST	AL,MASK SEG_CV_SYMBOLS1	;BOTH SET MEANS BORLAND NAMES
		JNZ	SK_MB_NAMES
		TEST	AH,MASK FL_DEBUG_TYPES
		JZ	SKIPIT_1
		JMP	SKIPIT_RET

SK_MB_NAMES:
		TEST	AH,MASK FL_DEBUG_TYPES + MASK FL_DEBUG_LOCALS
		JZ	SKIPIT_1
		JMP	SKIPIT_RET

endif

SKIPIT_1::
		XOR	EAX,EAX			;CLEAR ALL THIS SO FIXUPP
		RESS	LAST_DATA_KEEP,AL	;GETS IGNORED TOO
		MOV	LAST_DATA_PTR,EAX
		RET

OBJ_E::
		JZ	SKIPIT_1
		CALL	OBJ_PHASE
		JMP	SKIPIT_1

LEDATA		ENDP


		END

